// src/dto/user.ts
import { Rule, RuleType, PickDto } from '@midwayjs/validate';
const requiredString = RuleType.string().required();
export class UserDTO {
  @Rule(RuleType.string().min(1).max(200))
  userId: string;
  @Rule(requiredString.min(6).max(16))
  account: string;
  @Rule(requiredString.min(1).max(10))
  name: string;
  @Rule(requiredString.min(1).max(10))
  identity: string;
  @Rule(RuleType.string().min(1).max(10))
  sex: string;
  @Rule(requiredString.email())
  email: string;
  @Rule(requiredString.length(11))
  phone: string;
  @Rule(requiredString.min(6).max(16))
  password: string;
  @Rule(RuleType.string().max(160))
  hashPassword: string;
}
export class UpdateUserDTO {
  @Rule(RuleType.string().min(1).max(200))
  userId: string;
  @Rule(RuleType.string().min(1).max(128).optional())
  departmentId?: string;
  @Rule(RuleType.string().min(1).max(10).optional())
  sex?: string;
  @Rule(RuleType.string().email().optional())
  email?: string;
  @Rule(RuleType.string().length(11).optional())
  phone?: string;
  @Rule(RuleType.string().min(6).max(16).optional())
  password?: string;
}
export class AdminUpdateUserDTO extends UpdateUserDTO {
  @Rule(RuleType.string().min(1).max(10))
  identity: string;
  @Rule(RuleType.number().min(0).max(1))
  validFlag: number;
  @Rule(RuleType.boolean())
  remakePassword: boolean;
  @Rule(RuleType.number().min(1).max(3))
  authenticationFlag: number;
  @Rule(RuleType.string().min(1).max(16))
  name: string;
}
export class LoginDTO extends PickDto(UserDTO, [
  'account',
  'password',
  'hashPassword',
]) {}
//PickDto选定继承对象中的属性，OmitDto剔除继承对象中的属性
export class UserIdentityDTO {
  @Rule(requiredString.min(6).max(200))
  userId: string;
  @Rule(RuleType.number().required().min(0).max(2))
  validFlag: number;
  @Rule(RuleType.string().min(1).max(255))
  text: string;
}
